﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;

/// <summary>
/// Summary description for KhachHangDAO
/// </summary>
/// 
namespace Web_cuiki
{
    public class NhaVanChuyenDAO
    {

        public NhaVanChuyenDAO()
        {

        }

        public static NHA_VAN_CHUYEN TimTenTheoMa(string ma)
        {
            if (ma == "")
            {
                NHA_VAN_CHUYEN blank = new NHA_VAN_CHUYEN();
                blank.TenNhaVanChuyen = "";
                return blank;
            }

            int maNVC = Int32.Parse(ma);
            NhaXuatBanDataContext db = new NhaXuatBanDataContext();
            var query = from kh in db.NHA_VAN_CHUYENs where kh.MaNhaVanChuyen == maNVC select kh;
            NHA_VAN_CHUYEN kq = query.First<NHA_VAN_CHUYEN>();
            return kq;

        }
        public static NHA_VAN_CHUYEN TimMaTheoTen(string ten)
        {
            if (ten == "")
            {
                NHA_VAN_CHUYEN blank = new NHA_VAN_CHUYEN();
                blank.MaNhaVanChuyen = 0;
                return blank;
            }
            NhaXuatBanDataContext db = new NhaXuatBanDataContext();
            var query = from kh in db.NHA_VAN_CHUYENs where kh.TenNhaVanChuyen == ten select kh;
            NHA_VAN_CHUYEN kq = query.First<NHA_VAN_CHUYEN>();
            return kq;

        }
       
    }
}